package edu.ccut.titan.tag.report.exporter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRAbstractExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXlsExporterParameter;

public class ExcelReportExporter extends AbstractReportExporter {

	@Override
	protected JRAbstractExporter creatExporter() {
		return new JRXlsExporter();
	}

	@Override
	protected void setContentType(HttpServletResponse response) {
		response.setContentType("application/vnd.ms-excel");
	}

	@Override
	protected void setParameters(JRAbstractExporter exporter,
			HttpServletRequest request, HttpServletResponse response) {
		super.setParameters(exporter, request, response);
		exporter.setParameter(
				JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS,
				true);
		exporter
				.setParameter(
						JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
						true);
		exporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND,
				false);
		exporter
				.setParameter(JRXlsExporterParameter.IS_COLLAPSE_ROW_SPAN, true);
		exporter.setParameter(JRXlsExporterParameter.IS_IGNORE_CELL_BORDER,
				false);
	}

}
